package com.cattest.cattest.dao;

import com.cattest.cattest.entity.UserEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @Author linlx
 * @Date 2021/8/21 16:42
 * @Description
 **/
@Mapper
public interface UserMapper {

  @Select("SELECT * FROM `user` WHERE id = #{id}")
  UserEntity selectById(@Param("id") int id);

  @Update("UPDATE `user` SET real_name = #{realName} WHERE id = #{id}")
  void updateById(@Param("id") int id, @Param("realName") String realName);

  @Delete("DELETE FROM `user` WHERE id = #{id}")
  void deleteById(@Param("id") int id);

  @Insert("INSERT INTO user (user_name, pass_word, real_name) VALUES (#{userName}, #{passWord}, #{realName})")
  void save(@Param("userName") String userName, @Param("passWord") String passWord,
      @Param("realName") String realName);
}

